import 'package:flutter/material.dart';

class CaveHousePage extends StatefulWidget {
  @override
  _CaveHousePageState createState() => _CaveHousePageState();
}

class _CaveHousePageState extends State<CaveHousePage> {
  static final TextEditingController _foodLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _ironThisLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _ironTargetLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _woodThisLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _woodTargetLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _grassThisLevelController =
      TextEditingController(text: "0");
  static final TextEditingController _grassTargetLevelController =
      TextEditingController(text: "0");

  @override
  Widget build(BuildContext context) {
    return Container(
      child: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            buildFood(),
            Divider(),
            buildIron(),
            Divider(),
            buildWood(),
            Divider(),
            buildGrass(),
            Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: FlatButton(
                    child: Text("计算"),
                    textColor: Colors.black,
                    color: Colors.blue,
                    shape: RoundedRectangleBorder(
                      side: BorderSide(
                        color: Colors.white,
                        width: 1,
                      ),
                      borderRadius: BorderRadius.circular(8),
                    ),
                    onPressed: () {},
                  ),
                ),
                Expanded(
                  flex: 2,
                  child: Column(
                    children: <Widget>[
                      Text("木材仆役："),
                      Text("灵草仆役："),
                      Text("玄铁仆役："),
                      Text("预计时间：小时"),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Row buildGrass() {
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
          child: Text("灵草"),
        ),
        Expanded(
          flex: 3,
          child: Column(
            children: <Widget>[
              Text("当前数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _grassThisLevelController,
              ),
              Text("目标数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _grassTargetLevelController,
              ),
            ],
          ),
        )
      ],
    );
  }

  Row buildWood() {
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
          child: Text("木材"),
        ),
        Expanded(
          flex: 3,
          child: Column(
            children: <Widget>[
              Text("当前数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _woodThisLevelController,
              ),
              Text("目标数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _woodTargetLevelController,
              ),
            ],
          ),
        )
      ],
    );
  }

  Row buildIron() {
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
          child: Text("玄铁"),
        ),
        Expanded(
          flex: 3,
          child: Column(
            children: <Widget>[
              Text("当前数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _ironThisLevelController,
              ),
              Text("目标数量"),
              TextField(
                keyboardType: TextInputType.number,
                controller: _ironTargetLevelController,
              ),
            ],
          ),
        )
      ],
    );
  }

  Row buildFood() {
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
          child: Text("食物等级"),
        ),
        Expanded(
          flex: 3,
          child: TextField(
            keyboardType: TextInputType.number,
            controller: _foodLevelController,
          ),
        )
      ],
    );
  }
}
